import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class GenerationMain {

	/**
	 * @param args
	 * @throws IOException 
	 */
	
	/* This main function is basically here to test the underlying infrastructure. It allows the player to navigate
	 * the maze from the console, and allows the player to win.
	 */
	public static void main(String[] args) throws IOException {
		// test highscore system...
		/*
		HighscoreManager scoreManager = new HighscoreManager();
		scoreManager.clearScores();
		scoreManager.submitScore("Andrew", 100.0f);
		scoreManager.submitScore("Bobbert", 10.0f);
		scoreManager.submitScore("jimmy", 50.0f);
		
		System.out.println( scoreManager.scoreCount() );
		for ( int i = 0; i < scoreManager.scoreCount(); i ++ ) {
			System.out.println( scoreManager.nameForIndex(i) );
		}
		*/
		
		boolean done = false;
				
		GameState game = new GameState( 15, 15 );
		game.printGame();
		
		while( !done ) {
			BufferedReader r = new BufferedReader(new InputStreamReader (System.in));
			String input = r.readLine();
			
			switch ( input ) {
			case "u":
				game.movePlayer(0, -1);
				break;
			case "d":
				game.movePlayer(0, 1);
				break;
			case "l":
				game.movePlayer(-1, 0);
				break;
			case "r":
				game.movePlayer(1, 0);
				break;
			case "quit":
				done = true;
				break;
			}
			
			if ( game.playerAtExit() ) {
				done = true;
				System.out.println( "Yay! You won!" );
			}
			
			game.printGame();
		}
	}

}
